package com.amado.course34Thread;

/**
 * 线程组表示一个线程的集合。此外，线程组也可以包含其他线程组。
 * <P>
 * 线程组构成一棵树，在树中，除了初始线程组外，每个线程组都有一个父线程组。
 */
public class S07ThreadGroupTest {

	public static void main(String[] args) {
		//线程组的名字 thread-group
		ThreadGroup threadGroup = new ThreadGroup("thread-group");
		Thread thread = new Thread(threadGroup, new Runnable() {

			@Override
			public void run() {
				for (int i = 0; i < 5; i++) {
					System.out.println(Thread.currentThread().getThreadGroup().getName() + "   "
							+ Thread.currentThread().getName() + " = " + i);
					try {
						Thread.sleep(523);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		}, "myThread");
		thread.start();
	}
}
